using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Mvvm.UI;
using LayoutPlanning.Model;
using Mvvm.UI.Behaviors.EventToCommand;


namespace LayoutPlanning.Converters
{
    public class MouseButtonEventArgsToStationConverter : EventArgsConverterBase<DragEventArgs>
    {
        protected override object Convert(object sender, DragEventArgs args)
        {
            var station = args.Data.GetData(typeof (Station)) as GraficalObject;
            if (station == null)
                return null;

            var point = args?.GetPosition(sender as Panel);
            station.Position = point;
            return station;
        }
    }

    public class MouseButtonEventArgsToPointConverter : EventArgsConverterBase<MouseButtonEventArgs>
    {
        protected override object Convert(object sender, MouseButtonEventArgs value)
        {
            var args = (MouseButtonEventArgs) value;

            return args?.GetPosition(sender as Panel);
        }
    }
}